<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>更新页面</title>
    <th:block th:include="material/core/resources::headers"/>
</head>
<body>
<div>
    <form class="layui-form" th:object="${user1}">
        <div class="layui-form-item">
            <label for="id"><span>编号</span></label>
            <!--th:value="*{id}"-->
            <div><input type="text" name="id" id="id" th:value="*{id}" readonly="readonly"></div>唯一id不可修改
        </div>
        <div class="layui-form-item">
            <label for="name"><span>姓名</span></label>
            <div><input type="text" id="name" name="name" th:value="*{name}"></div>
        </div>
        <div class="layui-form-item">
            <label for="age"><span>年龄</span></label>
            <div><input type="text" id="age" name="age" th:value="*{age}"></div>
        </div>
        <div class="layui-form-item">
            <label for="email"><span>邮箱</span></label>
            <div><input type="text" id="email" name="email" th:value="*{email}"></div>
        </div>
        <div class="layui-form-item">
            <label for="createTime"><span>创建时间</span></label>
            <div><input type="text" id="createTime" readonly="readonly" placeholder="系统自动填充"></div>
        </div>
        <div class="layui-form-item">
            <label for="updateTime"><span>更新时间</span></label>
            <div><input type="text"  id="updateTime" readonly="readonly" placeholder="系统自动填充"></div>
        </div>
        <div>
            <button lay-filter="update" lay-submit="update">添加</button>
            <button type="reset">重置</button>
        </div>
    </form>
</div>
</body>
</html>

<script>layui.use(['form' ,'layer', 'jquery'],
    function () {
        const $ = layui.jquery;
        const form = layui.form, layer = layui.layer;
        form.on('submit(update)',
            function (data) {
            $.ajax({
                    url: "/spring/user/updateInfo",
                    type: "post",
                    /* layui 中的数据是根据 name属性 获取的 */
                    data: data.field,
                    success(res) {
                        if (res.success) {
                            layer.alert("修改成功啊🐇", {
                                    icon: 6
                                },
                                function () {
                                    xadmin.close();
                                    xadmin.father_reload();
                                });
                        } else {
                            layer.msg(res.msg)
                        }
                    }
                })
                return false;
            });
    });
</script>